﻿

function main() {
    showLog("抖音(上传视频1639");
    var testVersion = "(201902201431)版";
    var softwareName = "抖音";
    var resData = RequestEngine.getResData();
    var text = "";
    AccessibilityEngine.log("resData"+resData);
    var resJson = JSON.parse(resData);
    if (resJson.resText != undefined && resJson.resText != "") {
        var resText = eval('(' + resJson.resText + ')');
        text = resText[0];
    }
	if (AccessibilityEngine.checkUpId(widget.pages.shouye.wzdl) == ISTRUE) { //我知道了
        AccessibilityEngine.mockOnClickId(widget.pages.shouye.wzdl);
    }
    AccessibilityEngine.log(widget.pages.xaingce.xaingcedian+"widget.pages.xaingce.xaingcedian");
    AccessibilityEngine.sleepEngine(6000);//等待
    AccessibilityEngine.mockOnClickClassText(widget.pages.xaingce.xaingcedian,"相册");
    AccessibilityEngine.sleepEngine(6000);//等待
	if (AccessibilityEngine.checkUpId(widget.pages.shouye.wzdl) == ISTRUE) { //我知道了
        AccessibilityEngine.mockOnClickId(widget.pages.shouye.wzdl);
    }
    for (var i = 0; i < AccessibilityEngine.getIdNum("com.miui.gallery:id/album_name"); i++) {
        var SPText1 = AccessibilityEngine.getEditTextIndex("com.miui.gallery:id/album_name", i);
        if ( SPText1 == "视频" ) { 
            var wodeXY = JSON.parse( AccessibilityEngine.getBoundsCenterIdIndex("com.miui.gallery:id/album_name", i) );
            AccessibilityEngine.log("X:"+wodeXY.centerX);
            AccessibilityEngine.log("Y:"+wodeXY.centerY);

            if( jixing == 1 ){// 判断机型
                var pressjixing = "press," + parseX(wodeXY.centerX) + "," + parseY(wodeXY.centerY);
                ScreenEngine.currency(pressjixing);
            } else if( jixing == 2 ){
                ScreenEngine.swipe(parseX(wodeXY.centerX+100), parseY(wodeXY.centerY*0.67), parseX(wodeXY.centerX+100), parseY(wodeXY.centerY*0.67), 500);
            }
            break;
        }
    }
    showLog("111111111111111111111111");
    AccessibilityEngine.sleepEngine(5000);//等待
	if (AccessibilityEngine.checkUpId(widget.pages.shouye.wzdl) == ISTRUE) { //我知道了
        AccessibilityEngine.mockOnClickId(widget.pages.shouye.wzdl);
    }
    var wodeXYA = JSON.parse( AccessibilityEngine.getBoundsCenterIdIndex(widget.pages.xaingce.diyigeshipin,0) );
    AccessibilityEngine.log("X:"+wodeXYA.centerX);
    AccessibilityEngine.log("Y:"+wodeXYA.centerY);
    if( jixing == 1 ){// 判断机型
        var pressjixing = "press," + parseX(wodeXYA.centerX) + "," + parseY(wodeXYA.centerY);
        ScreenEngine.currency(pressjixing);
    } else if( jixing == 2 ){
        ScreenEngine.swipe(parseX(wodeXYA.centerX*0.67), parseY(wodeXYA.centerY*0.67), parseX(wodeXYA.centerX*0.67), parseY(wodeXYA.centerY*0.67), 500);
    }

    AccessibilityEngine.sleepEngine(3000);//等待
    if( jixing == 1 ){// 判断机型
        var pressdian = "press," + parseX(350) + "," + parseY(850);
        ScreenEngine.currency(pressjixing);
    } else if( jixing == 2 ){
        var pressdian = "press," + parseX(350*0.67) + "," + parseY(850*0.67);
    }

    ScreenEngine.currency(pressdian);
    AccessibilityEngine.sleepEngine(3000);//等待
    for (var i =0; i<3 ;i++ ){
        if (AccessibilityEngine.checkTextByClass(widget.pages.xaingce.fasong, "发送") == 1) {
            AccessibilityEngine.mockOnClickClazzText(widget.pages.xaingce.fasong, "发送");
            break;
        }else {
            var pressdian = "press," + parseX(350*0.67) + "," + parseY(850*0.67);
            ScreenEngine.currency(pressdian);
        }
    }
    if (AccessibilityEngine.checkUpIdText(widget.pages.xaingce.douyinduanshipin,"抖音短视频") == 1) {
        AccessibilityEngine.mockOnClickIdText(widget.pages.xaingce.douyinduanshipin, "抖音短视频"); //抖音短视频
    }
    AccessibilityEngine.sleepEngine(10000);//等待
   
    if (AccessibilityEngine.checkUpId(widget.pages.xaingce.yunxu) == ISTRUE) { //允许访问
        AccessibilityEngine.mockOnClickId(widget.pages.xaingce.yunxu);
    }

	AccessibilityEngine.mockOnClickIdText("com.ss.android.ugc.aweme:id/dtj", "下一步");
    
    AccessibilityEngine.sleepEngine(60000);//等待
    
    AccessibilityEngine.mockOnClickIdText("com.ss.android.ugc.aweme:id/c23", "下一步");
    AccessibilityEngine.sleepEngine(5000);//等待
  
   
    AccessibilityEngine.mockEditId(widget.pages.sahnghcuanshipin.biaoti, text); //赋值
    AccessibilityEngine.sleepEngine(3000);//等待
    AccessibilityEngine.mockOnClickId(widget.pages.sahnghcuanshipin.fabu); //发布
    AccessibilityEngine.sleepEngine(10000);//等待
    showLog("显示执行成功");
    setTaskState("5", "脚本执行完毕");
    throw SyntaxError();

}

var nihao22323= PhoneEngine.deleteDirectory(RequestEngine.getSdcardPath()+"DCIM/Camera")
var publicfunction = RequestEngine.getPluginPath() + "OS_DYCOMMON/publicfunction.js";
include(publicfunction); //公共方法js
var widgetPath = dyConditionCheck();
var widgetbyid = RequestEngine.getPluginPath() +"OS_DYCOMMON/"+ widgetPath;
include(widgetbyid);


AccessibilityEngine.sleepEngine(10000);//等待

if (AccessibilityEngine.checkUpId(widget.pages.shouye.bugengxin) == ISTRUE) { //更新以后再说
    AccessibilityEngine.mockOnClickId(widget.pages.shouye.bugengxin);
}
var jixing = getXYByIdIndex(widget.pages.shouye.wode);

var packageName = "com.miui.gallery";
var startActivity = "com.miui.gallery.activity.HomePageActivity";

AccessibilityEngine.mockLanuch(packageName, startActivity);

main();